import { Injectable } from '@angular/core';
import {NzMessageService  } from 'ng-zorro-antd';

@Injectable()
export class NotificationService {

    constructor(
        private notify: NzMessageService
    ) {

    }

    info(message: string, title?: string, options?: any): void {
        this.createNotification('info', message, title);
    }

    success(message: string, title?: string, options?: any): void {
        this.createNotification('success', message, title);
    }

    warn(message: string, title?: string, options?: any): void {
        this.createNotification('warn', message, title);
    }

    error(message: string, title?: string, options?: any): void {
        this.createNotification('error', message, title);
    }

    createNotification = (type, message, title?: string, options?: any) => {
        const t = title || message;
        this.notify.create(type, message, { nzDuration: 2000 });
    }
    
}
